package cn.taobaoke.restful

import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import org.springframework.boot.Banner
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.web.servlet.ServletComponentScan
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Bean

val logger: Logger = LogManager.getLogger(Application::class.java)

@SpringBootApplication
@ServletComponentScan
class Application {

    @Bean
    fun commandLineRunner(ctx: ApplicationContext): CommandLineRunner {
        return CommandLineRunner {
            val beanNames = ctx.beanDefinitionNames
            logger.info("Loading beans: ${beanNames.size}")
        }
    }
}

fun main(args: Array<String>) {
    val application = SpringApplication(Application::class.java)
    application.setBannerMode(Banner.Mode.OFF)
    application.run(*args)
//    val context = application.run(*args)
//    context.getBean(CheckRobotStatusTask::class.java).start()  // 启动监控机器人状态务
}
